using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_IOS&&!DEVELOP
using System.Runtime.InteropServices;
#endif
namespace QQSDK
{
    public class AttributionManager

    {

#if UNITY_EDITOR || DEVELOP

#elif UNITY_IOS && !DELSDK

        [DllImport("__Internal")]
        private static extern void initAttribution();

        //AF

        [DllImport("__Internal")]
        private static extern void logAppFlyerEvent(string eventName);
         [DllImport("__Internal")]
        private static extern void logAppFlyerEvent(string eventName,string eventValue);
        [DllImport("__Internal")]
        private static extern void logAppFlyerRevenue(string eventToken,string contentId,string orderId,bool priceStatus, double price, string currency);
         [DllImport("__Internal")]
        private static extern void logNewAppFlyerRevenue(string eventToken,string contentId, double price, string currency);

        ////热云-- 新版本热云删除，暂时注释相关方法
        //[DllImport("__Internal")]
        //private static extern void logReYunEvent(string eventToken);
        //[DllImport("__Internal")]
        //private static extern void logReYunRevenue(string ryTID, string ryzfType, string hbType, double price);

        //[DllImport("__Internal")]
        //private static extern void logReYunRegister(string account);
    
        //[DllImport("__Internal")]
        //private static extern void logReyunKeyAction(string eventName);
    
    
   
#elif UNITY_ANDROID
        public static AndroidJavaObject AJO;
#endif

        public static void Set()
        {
            SDKFunc.Log("设置归因");
#if UNITY_EDITOR || DEVELOP
            //Invoke("doOnInitAdsSucceed", 2);
#elif UNITY_IOS && !DELSDK
#elif UNITY_ANDROID
            AJO = SDKManager.SDK_Attribution;
#elif UNITY_WEBGL

#else

#endif
        }

        public static void InitAttribution()
        {
            SDKManager.InitAttribution();
        }

        #region AF


        /// <summary>
        /// AF基本打点事件.
        /// </summary>
        /// <param name="eventToken">事件token</param>
        public static void LogAppFlyerEvent(string eventName)
        {
            if (string.IsNullOrEmpty(eventName))
                return;
#if UNITY_EDITOR || DEVELOP
            SDKFunc.Log("LogAppFlyerEvent:" + eventName);
#elif UNITY_IOS && !DELSDK
            logAppFlyerEvent(eventName);
#elif UNITY_ANDROID
            if (AJO  != null)
                AJO.Call("logAppFlyerEvent", eventName);
#endif
        }


        /// <summary>
        /// AF自定义私参事件打点
        /// </summary>
        /// <param name="eventName">事件name</param>
        /// <param name="eventValue">事件私参</param>
        public static void LogAppFlyerEvent(string eventName, string eventValue)
        {
            if (string.IsNullOrEmpty(eventName))
                return;
#if UNITY_EDITOR || DEVELOP
            SDKFunc.Log("LogAppFlyerEvent:" + eventName + eventValue);
#elif UNITY_IOS && !DELSDK
            logAppFlyerEvent(eventName,eventValue);
#elif UNITY_ANDROID
            if (AJO  != null)
                AJO.Call("logAppFlyerEvent", eventName,eventValue);
#endif
        }

        /// <summary>
        /// AF 收入事件上报
        /// </summary>
        /// <param name="eventName">时间名称</param>
        /// <param name="id">产品ID</param>
        /// <param name="prices">价格</param>
        /// <param name="currency">货币</param>
        public static void LogAppFlyerRevenue(string eventName, string id, double prices, string currency)
        {
            if (string.IsNullOrEmpty(eventName))
                return;
#if UNITY_EDITOR || DEVELOP
            SDKFunc.Log("LogAppFlyerRevenue:" + eventName);
#elif UNITY_IOS && !DELSDK
            logNewAppFlyerRevenue(eventName, id, prices, currency);
#elif UNITY_ANDROID
            if (AJO  != null)
                AJO.Call("logAppFlyerRevenue", eventName, id, prices, currency);
#endif
        }

        /// <summary>
        /// AF 收入事件上报
        /// </summary>
        /// <param name="eventName">时间名称</param>
        /// <param name="id">产品ID</param>
        /// <param name="orderId">订单id</param>
        /// <param name="priceStatus">af_is_price_above_six</param>
        /// <param name="prices">价格</param>
        /// <param name="currency">货币</param>
        public static void LogAppFlyerRevenue(string eventName, string id, string orderId, bool priceStatus, double prices, string currency)
        {
            if (string.IsNullOrEmpty(eventName))
                return;
#if UNITY_EDITOR || DEVELOP
            SDKFunc.Log("LogAppFlyerRevenue:" + eventName);
#elif UNITY_IOS && !DELSDK
            logAppFlyerRevenue(eventName,id,orderId,priceStatus,prices,currency);
#elif UNITY_ANDROID
            if (AJO  != null)
                AJO.Call("logAppFlyerRevenue", eventName, id, orderId, priceStatus, prices, currency);
#endif
        }

        #endregion

        #region 热云 -- 新版本热云删除，暂时注释相关方法
        //        /// <summary>
        //        ///初始化热云.
        //        /// </summary>
        //        /// <param name="eventToken">事件token</param>
        //        public static void InitReYunSDK(string appKey, string channelId)
        //        {
        //#if UNITY_EDITOR || DEVELOP
        //            SDKFunc.Log("InitReYunSDK");
        //#elif UNITY_IOS && !DELSDK
        //            initReYunSDK(appKey);
        //#elif UNITY_ANDROID
        //            if (AJO  != null)
        //                AJO.Call("initReyun", SDKManager.GetCurrentlyActivity(),appKey,channelId);
        //#endif
        //        }



        /// <summary>
        ///热云基本打点事件.
        /// </summary>
        /// <param name="eventToken">事件token</param>
        //        public static void LogReYunEvent(string eventToken)
        //        {
        //            if (string.IsNullOrEmpty(eventToken))
        //                return;
        //#if UNITY_EDITOR || DEVELOP
        //            SDKFunc.Log("LogReyunEvent:" + eventToken);
        //#elif UNITY_IOS && !DELSDK
        //            logReYunEvent(eventToken);
        //#elif UNITY_ANDROID
        //            if (AJO  != null)
        //                AJO.Call("setTrackingEvent", eventToken);
        //#endif
        //        }

        /// <summary>
        /// 热云 应用内购收入事件上报
        /// </summary>
        /// <param name="transitionID">内购事件token</param>
        /// <param name="prices">价格</param>
        /// <param name="currency">货币</param>
        /// <param name="payType">支付类型，GooglePlay或者ApplePay</param>
        //        public static void LogReYunRevenueEvent(string transitionID, double currencyAmount, string currencyType, string paymentType)
        //        {
        //#if UNITY_EDITOR || DEVELOP
        //            SDKFunc.Log("LogReYunRevenueEvent:" + currencyAmount);
        //#elif UNITY_IOS && !DELSDK
        //            logReYunRevenue(transitionID, paymentType, currencyType, currencyAmount);
        //#elif UNITY_ANDROID
        //            if (AJO  != null)
        //                AJO.Call("logReYunRevenue", transitionID, currencyAmount , currencyType, paymentType);
        //#endif
        //        }

        /// <summary>
        /// 热云 关键事件数仓上报
        /// </summary>
        /// <param name="eventName">热云后台关键事件eventName</param>
        //        public static void LogToTBKeyAction(string eventName)
        //        {
        //#if UNITY_EDITOR || DEVELOP
        //            SDKFunc.Log("LogToTBReyunKeyAction:" + eventName);
        //#elif UNITY_IOS && !DELSDK
        //            logReyunKeyAction(eventName);
        //#elif UNITY_ANDROID
        //            if (AJO  != null)
        //                AJO.Call("logTBAction", eventName);
        //#endif
        //        }


        /// <summary>
        /// 热云 应用注册事件上报
        /// </summary>
        /// <param name="account">accountId</param>
        //        public static void LogReYunRegisterEvent(string account)
        //        {
        //#if UNITY_EDITOR || DEVELOP
        //            SDKFunc.Log("LogReYunRegisterEvent:" + account);
        //#elif UNITY_IOS && !DELSDK
        //            logReYunRegister(account);
        //#elif UNITY_ANDROID
        //            if (AJO  != null)
        //                AJO.Call("logReYunRegister", account);
        //#endif
        //        }

        #endregion


    }



    public class AttributionData
    {
        public string att_network = "";
        public string att_campaign = "";
        public string att_adgroup = "";
        public string att_creative = "";
        public string att_tracker = "";
    }
}